
$(function () {
    $('.menu li a').click(function () {
        //获取当前选中的li
        var _selectedIndex = 0, _aniDirection = "";
        $('.menu li').each(function (index, item) {
            if ($(item).hasClass("selected")) {
                _selectedIndex = $(item).attr("tab-index");
            }
        });
        //根据选中索引的大小判断tab 切换的方向
        _aniDirection = ($(this).parent('li').attr("tab-index") > _selectedIndex) ? "fadeInLeft" : "fadeInRight"
        //重置tab标签选中状态
        $('.menu li').removeClass("selected");
        $(this).parent('li').addClass("selected");
        var thisItem = $(this).attr('rel');
        $('.row-fluid-chart>div[rel!=' + thisItem + ']').hide();
        $('.row-fluid-chart>div[rel=' + thisItem + ']').each(function (index, obj) {
            //添加白色遮罩和和文字模拟加载提示效果
            $(obj).children(".chart-default").append("<div class='temp-float-div'></div>");
            $(obj).children(".chart-default").append('<div class="mc-chart-error"><span>努力的读取数据中...</span></div>');
            //给”移动计费“中的总量图表也添加”加载中”提示
            $(obj).children(".children-chart").children(".chart-default").append("<div class='temp-float-div'></div>");
            $(obj).children(".children-chart").children(".chart-default").append('<div class="mc-chart-error"><span>努力的读取数据中...</span></div>');
            setTimeout(function () {
                $(obj).addClass("animated " + _aniDirection).show();
            }, index * 80);
        });
        setTimeout(function(){
            _chartsResizeFn();
            $(".mc-chart-error").remove();
            $(".temp-float-div").remove();
            _chartsResizeFn();
        },1800);
        $(window).bind("blur focus",function(){   //修复页面失去焦点后图标区域宽度变化的bug
            _chartsResizeFn();
        });
    });
})